package com.jingdianjichi.subject.infra.basic.service.impl;

import com.alibaba.fastjson.JSON;
import com.jingdianjichi.subject.infra.basic.entity.SubjectMultiple;
import com.jingdianjichi.subject.infra.basic.mapper.SubjectMultipleDao;
import com.jingdianjichi.subject.infra.basic.service.SubjectMultipleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 多选题信息表(SubjectMultiple)表服务实现类
 *
 * @author makejava
 * @since 2025-07-19 13:35:37
 */
@Service("subjectMultipleService")
@Slf4j
public class SubjectMultipleServiceImpl implements SubjectMultipleService {

    @Resource
    private SubjectMultipleDao subjectMultipleDao;

    /**
     * 新增数据
     *
     * @param subjectMultiple 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectMultiple insert(SubjectMultiple subjectMultiple) {
        if(log.isInfoEnabled()){
            log.info("SubjectMultipleServiceImpl.insert.subjectMultiple:{}"
                    , JSON.toJSONString(subjectMultiple));
        }
        this.subjectMultipleDao.insert(subjectMultiple);
        return subjectMultiple;
    }

    @Override
    public SubjectMultiple queryById(Long id) {
        return this.subjectMultipleDao.queryById(id);
    }

    /**
     * 修改数据
     *
     * @param subjectMultiple 实例对象
     * @return 影响行数
     */
    @Override
    public int update(SubjectMultiple subjectMultiple) {
        return this.subjectMultipleDao.update(subjectMultiple);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.subjectMultipleDao.deleteById(id) > 0;
    }

    @Override
    public List<SubjectMultiple> queryBySubjectId(Long subjectId) {
        return this.subjectMultipleDao.queryBySubjectId(subjectId);
    }

    @Override
    public int insertBatch(List<SubjectMultiple> subjectMultipleList) {
        if(log.isInfoEnabled()){
            log.info("SubjectMultipleServiceImpl.insertBatch.subjectMultipleList:{}"
                    , JSON.toJSONString(subjectMultipleList));
        }
        return this.subjectMultipleDao.insertBatch(subjectMultipleList);
    }
}